package com.example.forum.exception;

import com.example.forum.common.AppResult;
/**
 * 自定义异常
 */
public class ApplicationException extends RuntimeException{
    // 在异常中持有一个错误信息
    protected AppResult errorResult;

    public ApplicationException(AppResult appResult){
        super(appResult.getMessage()); // 调用父类方法,将错误信息传进去
        this.errorResult = appResult;
    }
    public AppResult getErrorResult(){
        return errorResult;
    }

    public ApplicationException(String message) {
        super(message);
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }

    public ApplicationException(Throwable cause) {
        super(cause);
    }
}
